package zuoye3;

public class Zy2 {
    public static void main(String[] args) {
        int[] sz1 = {1,3,4,3,0,2,6,6,8,5,4,8,4,7,0,5};
        int arr = lenght(sz1);
        int[] sz2 = getsz2(sz1, arr);
        print(sz1);
        print(sz2);
        getCha(sz1, sz2);
    }
    public static int lenght(int[] array){
        int x = 0;
        for(int i = 0 ; i < array.length;i++){
            if(array[i] != 0){
                x++;
            }
        }
        return x;
    }

    public static int[]  getsz2(int[] array,int num){
        int[] newArray = new int[num];
        int y = 0;
        for(int i = 0; i < array.length; i ++){
            if(array[i]!=0){
                newArray[y] = array[i];
                y++;
            }
        }
        return newArray;
    }
    public static void print(int [] array){
        for(int i : array){
            System.out.print(i+" ");
        }
        System.out.println();
    }
    public static void getCha(int[] oldArray,int[] newArray){
        System.out.println("两个数组差"+(oldArray.length-newArray.length)+"个元素");
    }
}
